<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <!-- 开启理想视口: 将布局视口改成了当前设备独立像素的宽度 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      #test {
        width: 100%;
        height: 100px;
        background-color: red;
      }
    </style>
  </head>
  <body>
    <h1 id="title"></h1>
    <!-- <div id="test"></div> -->

    <script>
      //   console.log('移动端布局视口:', document.documentElement.clientWidth)
      document.getElementById('title').innerText =
        document.documentElement.clientWidth
      //   console.log('视觉视口:', window.innerWidth)
      //   document.getElementById('title').innerText = window.innerWidth
    </script>
  </body>
</html>
